package com.he.config;

import com.he.interceptor.TokenInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author 布衣
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Resource
    private TokenInterceptor tokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/adminUser/login", "/adminUser/logout", "/adminUser/register","/product/uploadTempImageWithDb","/product/confirmImageWithDb","/product/cancelImage**")
                .excludePathPatterns("/swagger**/**")   // 排除swagger相关路径
                .excludePathPatterns("/webjars/**")     // 排除webjars路径
                .excludePathPatterns("/v3/**")          // 排除v3路径
                .excludePathPatterns("/doc.html");      // 排除knife4j路径;
    }

}
